﻿--[[	$Id: readyCheck.lua 2365 2011-12-05 21:43:07Z sdkyron@gmail.com $	]]

local _, caelCore = ...

--[[	Force readycheck warning, auto accept if buffed	]]

caelCore.readycheck = caelCore.createModule("ReadyCheck")

local readycheck = caelCore.readycheck

local GetSpellName = function(spellId)
	return GetSpellInfo(spellId)
end

local flasks = {
	GetSpellName(80719), -- Flask of Steelskin
	GetSpellName(80720), -- Flask of the Draconic Mind
	GetSpellName(80721), -- Flask of the Winds
	GetSpellName(80723), -- Flask of Titanic Strength
	GetSpellName(94162), -- Flask of Flowing Water
}

ReadyCheckListenerFrame:SetScript("OnShow", nil)

readycheck:RegisterEvent("READY_CHECK")
readycheck:SetScript("OnEvent", function(self, event)
	if event == "READY_CHECK" then
		self:RegisterEvent("UNIT_AURA")

		PlaySoundFile([=[Sound\Interface\ReadyCheck.wav]=], "Master")

		local food = UnitBuff("player", "Well Fed")

		for k, v in pairs(flasks) do
			local flask = UnitBuff("player", k)

			if flask and food then
				ReadyCheckFrame:Hide(); ConfirmReadyCheck(1)
				self:UnregisterEvent("UNIT_AURA")
				break
			end
		end
	end
end)